<?php

	if(isset($_POST['phoneAreaCode'])&&isset($_POST['phonePrefix'])&&isset($_POST['phoneSuffix'])){
		require 'demo_credentials.php';

		$reaction="";
		$phone=$_POST['phoneAreaCode'].$_POST['phonePrefix'].$_POST['phoneSuffix'];
		if(preg_match("/^[2-9][0-9]{9}$/", $phone)){
			$data = array(
				'key'=>$agendizeKey,
				'id'=>$agendizeButtonId,
				'phone'=>'+1'.$phone,
			);
			$curl = curl_init('https://www.agendize.com/api/1.0/action?media=call&'.http_build_query($data));
			curl_setopt($curl, CURLOPT_USERPWD, $agendizeUsername . ":" . $agendizePassword);  
			curl_setopt($curl, CURLOPT_HTTPGET, 1);
			curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
			// If you experience SSL issues, perhaps due to an outdated SSL cert
			// on your own server, try uncommenting the line below
			// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
			$response = curl_exec($curl);
			curl_close($curl);

			libxml_use_internal_errors(true);
			$xml = new SimpleXMLElement($response);
			$response=$xml->result;
			$reaction='Calling +1'.$phone.'.';
			if($response!="200"){
				$reaction='Error encountered while calling +1'.$phone.': '.$response.'.';
			}else{
				$reaction='Calling +1'.$phone.', please allow 10-30 seconds to connect, Thank You!';
			};
		}else{
			$reaction="Phone number is invalid.";
		}
		echo "$reaction";
	}else{
?><!DOCTYPE html>
<!--[if lt IE 7 ]> <html class="ie ie6 no-js" lang="en"> <![endif]-->
<!--[if IE 7 ]>    <html class="ie ie7 no-js" lang="en"> <![endif]-->
<!--[if IE 8 ]>    <html class="ie ie8 no-js" lang="en"> <![endif]-->
<!--[if IE 9 ]>    <html class="ie ie9 no-js" lang="en"> <![endif]-->
<!--[if gt IE 9]><!--><html class="no-js" lang="en"><!--<![endif]-->
    <head>
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
		<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
		<link href="css/jquery-bubble-popup-v3.css" rel="stylesheet" type="text/css">
		<link rel="stylesheet" type="text/css" href="css/demo.css" />
		<link rel="stylesheet" type="text/css" href="css/style1_.css" />
		<link rel="stylesheet" type="text/css" href="css/callme.css" />
		<script src="js/modernizr.custom.86080.js" type="text/javascript"></script>
		<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
		<script src="js/jquery-bubble-popup-v3.min.js"> type="text/javascript"</script>
		<script src="js/default.js" type="text/javascript"></script>
    </head>
    <body id="page">
        <ul class="cb-slideshow">
            <li><span>Image 01</span><div><h3>All-Inclusive Trip to the Masters</h3></div></li>
            <li><span>Image 02</span><div><h3>The most spectacular competition <br>in one of the most beautiful back-drops</h3></div></li>
            <li><span>Image 03</span><div><h3>Join us on this once-in-a-lifetime experience</h3></div></li>
            <li><span>Image 04</span><div><h3>Immerse yourself in the Magnificence of <br>Augusta National Golf Course</h3></div></li>
            <li><span>Image 05</span><div><h3>Round trip airfare aboard a 737 Charter</h3></div></li>
            <li><span>Image 06</span><div><h3>Breakfast aboard the plane</h3></div></li>
            <li><span>Image 07</span><div><h3>Ticket to the Wednesday Practice Round<br> and Par 3 Tournament</h3></div></li>
            <li><span>Image 08</span><div><h3>Ground transfer to and from Augusta Airport</h3></div></li>
            <li><span>Image 09</span><div><h3>Open Bar aboard the plane</h3></div></li>
            <li><span>Image 10</span><div><h3>Cocktails and Hors d'Ouevres from 5:30 PM - 7:30 PM</h3></div></li>
            <li><span>Image 11</span><div><h3>All taxes and Gratuities</h3></div></li>
            <li><span>Image 12</span><div><h3>Special VIP Rate</h3></div></li>
            <li><span>Image 13</span><div><h3>Proceeds benefitting the Brentwood Soccer Club</h3></div></li>
            <li><span>Image 14</span><div><h3>Join us at the Masters in Augusta!</h3></div></li>
        </ul>
		<div class="container">
			<header>
				<h1>All-Inclusive Trip to the Masters</h1>
				<h2>EXTRAVAGANT.IO NextGen Presentation</h2>
			</header>
		</div>
		<div id="content">
			<div id="callForm">
				<span id="bgSpan">
				<form id="phoneForm" action="" method="post">
						<input class="phoneAreaCode" maxlength="3" name="phoneAreaCode" placeholder="555" size="3" type="text"><span id="dsSpan">-</span>
						<input class="phonePrefix" maxlength="3" name="phonePrefix" placeholder="555" size="3" type="text"><span id="dsSpan">-</span>
						<input class="phoneSuffix" maxlength="4" name="phoneSuffix" placeholder="5555" size="4" type="text">
						<input name="submit" type="submit" value="">
				</form>
				</span>
			</div>
		</div>
		<div id="broughtBy"></div>
	</body>
</html>
<?php }
?>
